package com.kaluli.system.security;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

public class UserDetailsServiceImpl implements UserDetailsService {
	
//	@Autowired
//	private UserRepository userRepository;

	@Override
	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException {
		Collection<GrantedAuthority> grantedAuths = obtionGrantedAuthorities();
//		com.abmart.project.domain.entity.User user = userRepository.findByName(username);
//		User userdetail = new User(user.getUsername() , user.getPassword() , grantedAuths);
//		return userdetail;
		return null;
		
	}

	/**
	 * 取得用户的权限
	 * 
	 * @param loginItem
	 * @return
	 */
	private Set<GrantedAuthority> obtionGrantedAuthorities() {
		Set<GrantedAuthority> authSet = new HashSet<GrantedAuthority>();
		authSet.add(new SimpleGrantedAuthority("ROLE_USER"));
		return authSet;
	}

}
